<?php

class SocNet 
{
	  public static function get_id($p_news_type, $p_links)
	 {		 
		 $first_part=mt_rand(1000, 9999);
		 $second_part=mt_rand(1000, 9999);
		 $third_part=mt_rand(1000, 9999);
		 $total_int=md5($first_part.$second_part.$third_part);		 
		 $values;
		 
		 if ($p_news_type=='photo')
		 {
			 foreach ($p_links as $k=>$v)
			 {
				 if (empty($values))
				 {
					 $values=$values."('$total_int','$v', NULL)";
				 }
				 else
				 {
					 $values=$values.", ('$total_int','$v', NULL)";
				 }				 
			 }
		 }
		 else
		 {
			 foreach ($p_links as $k=>$v)
			 {
				 if (empty($values))
				 {
					 $values=$values."('$total_int', NULL, '$v')";
				 }
				 else
				 {
					 $values=$values.", ('$total_int', NULL, '$v')";
				 }				 
			 }
		 }		 
		 
		 SQL::execute(Template::render("insertToSocNet.sql", "sql", array('values'=>$values)));	
		 return $total_int; 	  
	 }
	 
	 public static function getSharedPhotos($p_id)
	 {
		 return SQL::select(Template::render("getSharedPhotos.sql", "sql", array('id'=>$p_id)));	
	 }
	 
	  public static function getSharedVideos($p_id)
	 {
		 return SQL::select(Template::render("getSharedVideos.sql", "sql", array('id'=>$p_id)));	
	 }
	 
}